# cmake/FindQt.cmake


# ��� SC_QT_DIR ��������
if(DEFINED ENV{SC_QT_DIR})
    set(SC_QT_DIR $ENV{SC_QT_DIR})
    #  SC_QT_DIR ���� CMAKE_PREFIX_PATH
    list(APPEND CMAKE_PREFIX_PATH ${SC_QT_DIR})
    message(STATUS "Using SC_QT_DIR: ${SC_QT_DIR}")
endif()


# ���� Qt ����ģ��
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Xml Svg OpenGL Sql)
SET(Qt5_FOUND True)


# ���� Qt ����
if(Qt5_FOUND)

    FIND_LIBRARY(Qt5Core_LIBRARIES
        NAMES Qt5Core
        PATHS ${SC_QT_DIR}/lib
    )
    FIND_LIBRARY(Qt5Gui_LIBRARIES
        NAMES Qt5Gui
        PATHS ${SC_QT_DIR}/lib
    )
    FIND_LIBRARY(Qt5Xml_LIBRARIES
        NAMES Qt5Xml
        PATHS ${SC_QT_DIR}/lib
    )
    FIND_LIBRARY(Qt5Svg_LIBRARIES
        NAMES Qt5Svg
        PATHS ${SC_QT_DIR}/lib
    )
    FIND_LIBRARY(Qt5Widgets_LIBRARIES
        NAMES Qt5Widgets
        PATHS ${SC_QT_DIR}/lib
    )
    FIND_LIBRARY(Qt5OpenGL_LIBRARIES
        NAMES Qt5OpenGL
        PATHS ${SC_QT_DIR}/lib
    )
    FIND_LIBRARY(Qt5Sql_LIBRARIES
        NAMES Qt5Sql
        PATHS ${SC_QT_DIR}/lib
    )
    set(Qt_FOUND TRUE)
    set(Qt_INCLUDE_DIRS
        ${Qt5Core_INCLUDE_DIRS}
        ${Qt5Gui_INCLUDE_DIRS}
        ${Qt5Widgets_INCLUDE_DIRS}
        ${Qt5Xml_INCLUDE_DIRS}
        ${Qt5Svg_INCLUDE_DIRS}
        ${Qt5OpenGL_INCLUDE_DIRS}
        ${Qt5Sql_INCLUDE_DIRS}
    )
    set(Qt_LIBRARIES
        ${Qt5Core_LIBRARIES}
        ${Qt5Gui_LIBRARIES}
        ${Qt5Widgets_LIBRARIES}
        ${Qt5Xml_LIBRARIES}
        ${Qt5Svg_LIBRARIES}
        ${Qt5OpenGL_LIBRARIES}
        ${Qt5Sql_LIBRARIES}
    )
    set(Qt_DEFINITIONS
        ${Qt5Core_DEFINITIONS}
        ${Qt5Gui_DEFINITIONS}
        ${Qt5Widgets_DEFINITIONS}
        ${Qt5Xml_DEFINITIONS}
        ${Qt5Svg_DEFINITIONS}
        ${Qt5OpenGL_DEFINITIONS}
        ${Qt5Sql_DEFINITIONS}
    )
    set(Qt_VERSION ${Qt5Core_VERSION})
else()
    set(Qt_FOUND FALSE)
endif()

# ������ҽ��
if(Qt_FOUND)
    message(STATUS "Found Qt: ${Qt_LIBRARIES}")
else()
    message(FATAL_ERROR "Could not find Qt")
endif()